package com.shanzmoo.core.manager;

import com.shanzmoo.core.cache.CurrentUserCache;
import com.shanzmoo.db.order.entity.OutletOrderLogEntity;
import com.shanzmoo.db.order.entity.vo.OutletOrderLogVo;
import com.shanzmoo.db.order.service.IOutletOrderLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 *
 * @author： Gzhao 2021/1/31
 */
@Slf4j
@Component
public class OutletOrderLogManager {

    @Autowired
    private IOutletOrderLogService outletOrderLogService;

    /**
     * 保存订单日志
     *
     * @author Gzhao 2021/1/13
     * @param orderId 订单id
     * @param operation 操作描述
     * @return
     */
    public void saveLog(Integer orderId, String operation) {
        OutletOrderLogEntity outletOrderLogEntity = new OutletOrderLogEntity();
        outletOrderLogEntity.setOrderId(orderId);
        outletOrderLogEntity.setDescription(operation);
        outletOrderLogEntity.setCreateUser(CurrentUserCache.getUserId());

        outletOrderLogService.save(outletOrderLogEntity);
    }

    public List<OutletOrderLogVo> queryListByOrderId(Integer orderId, Integer outletId) {
        return outletOrderLogService.queryListByOrderId(orderId, outletId);
    }
}
